//
//  LBNamePriceView.m
//  loveBeen
//
//  Created by 韩天助 on 11/20/16.
//  Copyright © 2016 loveBeen. All rights reserved.
//

#import "LBNamePriceView.h"

@interface LBNamePriceView()
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *market_priceL;
@property (weak, nonatomic) IBOutlet UIView *xiexianV;

@end

@implementation LBNamePriceView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)setProductModel:(LBSuperMarketProducts *)productModel{
    _productModel = productModel;
    
    self.nameLabel.text = productModel.name;
    self.priceLabel.text = [NSString stringWithFormat:@"￥%@",productModel.partner_price];
    if ([productModel.partner_price isEqualToString:productModel.market_price]) {
        self.market_priceL.text = @"";
        self.xiexianV.hidden = YES;
    }else{
        
        self.market_priceL.text = [NSString stringWithFormat:@"￥%@",productModel.market_price];
        self.xiexianV.hidden = NO;
    }
    
    NSMutableAttributedString *newPrice = [[NSMutableAttributedString alloc] initWithString:_market_priceL.text];
    [newPrice addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, newPrice.length)];
    self.market_priceL.attributedText = newPrice;

}

+ (instancetype)namePriceView{
    UINib *nib = [UINib nibWithNibName:@"LBNamePriceView" bundle:nil];
    
    return [[nib instantiateWithOwner:nil options:nil] lastObject];
}

@end
